package dynamic.adapter;

import com.baomidou.mybatisplus.core.MybatisPlusVersion;
import com.baomidou.mybatisplus.core.toolkit.ExceptionUtils;
import com.github.yulichang.adapter.base.tookit.VersionUtils;
import dynamic.adapter.base.DITableInfoAdapter;
import dynamic.adapter.base.DTableInfoAdapter;

public class DAdapterHelper {
    private static final DITableInfoAdapter adapter;

    static {
        String version = MybatisPlusVersion.getVersion();
        if (VersionUtils.compare(version, "3.5.4") >= 0) {
            adapter = new DTableInfoAdapter();
        } else if (VersionUtils.compare(version, "3.4.0") >= 0) {
            adapter = new DTableInfoAdapter3431();
        } else if (VersionUtils.compare(version, "3.3.0") >= 0) {
            adapter = new DTableInfoAdapterV33x();
        } else {
            throw ExceptionUtils.mpe("MPJ需要MP版本3.3.0+，当前MP版本%s", version);
        }
    }

    public static DITableInfoAdapter getTableInfoAdapter() {
        return adapter;
    }
}
